//
//  ForwardingController.m
//  OnionHome
//
//  Created by fengjie on 2019/9/19.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "ForwardingController.h"

@interface ForwardingController ()
/**输入框*/
@property (nonatomic,strong)PubulicTextView*textView;

/**底部按钮视图*/
@property (nonatomic,strong)UIView*bottomTabarView;

@end

@implementation ForwardingController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavItems];
    [self createUI];
}

-(void)setNavItems{
    
    self.title = @"转发";
    
    UIButton * leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftBtn setTitle:@"取消" forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(backBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [leftBtn setTitleColor:UIColorFromRGB(0x273323) forState:UIControlStateNormal];
    leftBtn.titleLabel.font = SYSTEMFONT(16);
    [leftBtn sizeToFit];
    
    UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBtn setTitle:@"发布" forState:UIControlStateNormal];
    [rightBtn setTitleColor:UIColorFromRGB(0x009966) forState:UIControlStateNormal];
    rightBtn.titleLabel.font = SYSTEMFONT(16);
    [rightBtn sizeToFit];
    
    kWeakSelf(weakSelf);
    [rightBtn addActionHandler:^{
//        if (self.textView.textView.text.length == 0) {
//            ShowHubMessage(@"请添加分享的内容");
//            return ;
//        }
//        if (self.dataArray.count == 0) {
//            ShowHubMessage(@"请添加分享的图片");
//            return ;
//        }
        
        [weakSelf backBtnClicked];
    }];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    
    
}
-(void)createUI{
    [self.view addSubview:self.textView];
    
    UIView * botView = [self createBootomView];
    [self.view addSubview:botView];
    
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.height.mas_equalTo(100);
    }];
    
    UIView * bottomView = UIView.new;
    bottomView.backgroundColor = UIColorFromRGB(0xF5F7F5);
    
    [self.view addSubview:bottomView];
    
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(self.textView.mas_bottom).offset(16);
        make.right.mas_equalTo(-16);
    }];
    
    UIImageView * imageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(@"dynamicDefut")];
    imageView.image = IMAGE_NAMED([Utilis getRandomDynamicImage]);
    
    UILabel * userName = UILabel.new;
    userName.textColor = UIColorFromRGB(0x273323);
    userName.font = SYSTEMFONT(14);
    userName.text = @"@我是大鲨鱼";
    
    UILabel * contenLabel = UILabel.new;
    contenLabel.textColor = UIColorFromRGB(0x273323);
    contenLabel.font = SYSTEMFONT(14);
    contenLabel.numberOfLines = 3;
    contenLabel.text = @"做烤鸡的时候，千万别直接放进烤箱，多加一步，鸡肉更加入味鸡肉更加入味鸡肉更加入味鸡肉更加入味";

    
    [bottomView addSubview:imageView];
    [bottomView addSubview:userName];
    [bottomView addSubview:contenLabel];

    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.mas_equalTo(0);
        make.width.height.mas_equalTo(100);
    }];
    
    [userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageView.mas_right).offset(16);
        make.top.mas_equalTo(imageView.mas_top).offset(16);
        make.right.mas_equalTo(-5);
    }];
    [contenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(userName);
        make.right.mas_equalTo(-5);
        make.bottom.mas_equalTo(imageView.mas_bottom).offset(-16);
        make.top.mas_equalTo(userName.mas_bottom).offset(4);
    }];
    

}
#pragma mark --懒加载

-(PubulicTextView*)textView{
    if(!_textView){
        _textView=[[PubulicTextView alloc] initWithFrame:CGRectZero];
        _textView.placeholderText.text = @"说说你的看法";
        _textView.placeholderText.textColor = UIColorFromRGB(0x959E97);
        _textView.placeholderText.font = SYSTEMFONT(14);
        _textView.textView.textColor = UIColorFromRGB(0x273323);
        _textView.textView.font = SYSTEMFONT(14);
        self.bottomTabarView = [self createBootomView];
        _textView.textView.inputAccessoryView = self.bottomTabarView;
    }
    return _textView;
}
-(UIView *)createBootomView{
    UIView * view=[[UIView alloc] initWithFrame:CGRectMake(0, KScreenHeight-40-K_TopHeight, KScreenWidth, 40)];
    view.backgroundColor = UIColorFromRGB(0xF5F7F5);
    
    UIButton * button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setBackgroundImage:IMAGE_NAMED(@"zhuanfa_1") forState:UIControlStateNormal];
    
    UIButton * button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button2 setBackgroundImage:IMAGE_NAMED(@"zhuanfa_2") forState:UIControlStateNormal];
    
    UIButton * button3 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button3 setBackgroundImage:IMAGE_NAMED(@"zhuanfa_3") forState:UIControlStateNormal];
    

    [view addSubview:button1];
    [view addSubview:button2];
    [view addSubview:button3];

    [button1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.centerY.mas_equalTo(0);
    }];
    [button2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(button3.mas_left).offset(-20);
        make.centerY.mas_equalTo(0);
    }];
    [button3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.centerY.mas_equalTo(0);
    }];

    return view;
}
@end
